from urllib.request import urlopen, URLError

begin = 1
end = 10000
step = 30
init = False
spider_server_host = "http://127.0.0.1:5000"

if init:
    try:
        urlopen(spider_server_host + "/init", timeout = 10000)
    except URLError as err:
        print("初始化错误！" + err.reason)
        exit(233)

i = begin
while i < end:
    print("获取%d至%d数据" % (i, i+step-1))
    try:
        urlopen(spider_server_host + "/run/" + str(i) + "/" + str(i + step - 1), timeout = 10000)
    except URLError as err:
        print("获取数据时错误！" + err.reason)
        continue
    i += step
